package sg.edu.nus.iss.vmcs.controller;

import sg.edu.nus.iss.vmcs.util.VMCSException;
/**
 * 
 * @author Chomeaye
 *
 */
public class CoinReceiverIdle implements CoinReceiverState {

	
	private static CoinReceiverIdle instance = null;
	   private CoinReceiverIdle() {
	      
	   }
	   public static CoinReceiverIdle GetInstance() {
	      if(instance == null) {
	         instance = new CoinReceiverIdle();
	      }
	      return instance;
	   }

	@Override
	public void continueReceive(CoinReceiver coinReceiver) throws VMCSException {
	
		throw new VMCSException("CoinReceiver", "CoinReceiver is in Idle state. Cannot execute ContinueReceive function.");
		
	}

	@Override
	public void receiveCoin(CoinReceiver coinReceiver, double totAmtInserted)
			throws VMCSException {
	
		throw new VMCSException("CoinReceiver", "CoinReceiver is in Idle state. Cannot execute ReceiveCoin function.");
	}

	@Override
	public void refundCash(CoinReceiver coinReceiver) throws Exception {
	
		throw new VMCSException("CoinReceiver", "CoinReceiver is in Idle state. Cannot execute RefundCash function.");
	}

	@Override
	public void startCoinReceiver(CoinReceiver coinReceiver)
			throws VMCSException {
		
		
		//set coinReceiverIdle State 
		coinReceiver.setState(CoinReceiverIdle.GetInstance());
				
	}

	@Override
	public void startReceive(CoinReceiver coinReceiver) throws VMCSException {
			
		coinReceiver.setTotalInserted(0);			
		
		coinReceiver.setState(new CoinReceiving());
		
		
	}

	@Override
	public void stopCoinReceiver(CoinReceiver coinReceiver)
			throws VMCSException {
		
		
		coinReceiver.getTransactionController().allowCoinInputBoxSelection(false);
		coinReceiver.getTransactionController().allowDrinkSelectionBox(true);
		
		
		
	}

	@Override
	public void stopReceive(CoinReceiver coinReceiver) throws VMCSException {
		
		throw new VMCSException("CoinReceiver", "CoinReceiver is in Idle state. Cannot execute StopReceive function.");
		
	}

	@Override
	public boolean storeCash(CoinReceiver coinReceiver) throws VMCSException {
		
		throw new VMCSException("CoinReceiver", "CoinReceiver is in Idle state. Cannot execute StoreCash function.");
	}

	@Override
	public void terminateFault(CoinReceiver coinReceiver) throws Exception {
	
		throw new VMCSException("CoinReceiver", "CoinReceiver is in Idle state. Cannot execute TerminateFault function.");
	}

}
